package com.daiyang.campus_lucky_draw;

import com.daiyang.campus_lucky_draw.contreller.param.DrawPrizeParam;
import com.daiyang.campus_lucky_draw.contreller.param.ShowWinningRecordsParam;
import com.daiyang.campus_lucky_draw.service.DrawPrizeService;
import com.daiyang.campus_lucky_draw.service.dto.WinningRecordDTO;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;

@SpringBootTest
public class DrawPrize {
    @Autowired
    DrawPrizeService drawPrizeService;
    @Test
    void DrawPrize() {
        DrawPrizeParam param = new DrawPrizeParam();
        param.setActivityId(58L);
        param.setPrizeId(27L);
        param.setWinningTime(new Date());
        List<DrawPrizeParam.Winner> winnerList =  new ArrayList<>();
        DrawPrizeParam.Winner winner = new DrawPrizeParam.Winner();
        winner.setUserId(62L);
        winner.setUserName("1111");
        winnerList.add(winner);
        param.setWinnerList(winnerList);
        drawPrizeService.drawPrize(param);
    }
    @Test
    void showWinningRecords() {
        ShowWinningRecordsParam param = new ShowWinningRecordsParam();
        param.setActivityId(58L);
        //  param.setPrizeId(25L);
        List<WinningRecordDTO> list = drawPrizeService.getRecords(param);
        for (WinningRecordDTO dto : list) {
            // 中奖者_奖品_等级
            System.out.println(dto.getWinnerName()
                    + "_" + dto.getPrizeName()
                    + "_" +dto.getPrizeTier().getMessage());
        }
    }
}
